/**
    ATClab - scriptable Air Traffic Control simulations.
    Copyright (C) 2010 openatclab@gmail.com

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
**/

#ifndef __ATC_TASK_HDR__
#define __ATC_TASK_HDR__


#ifdef WIN32
	// disable - decorated name length exceeded
	#pragma warning(disable:4503)
	// disable 'identifier' truncation warning
	#pragma warning(disable:4786)
#endif


#include "document.h"
#include "logging/logger.h"
#include <q3accel.h>
#include <qdatetime.h>
#include <qkeysequence.h>
#include <qwidget.h>
//Added by qt3to4:
#include <QMouseEvent>
#include <QShowEvent>
#include <QKeyEvent>
#include <QHideEvent>

#include <set>


namespace pact {


	/*!
	 * \class atc::Task
	 */
	class Task : public QWidget, public xml::DocumentView {
		Q_OBJECT
	public:

		Task();
		virtual ~Task();

	public:
		void addTerminationKey( const QKeySequence& );
		void addTerminationKey( const QString& );
		virtual void addTerminationTime( int );
		int time() const { return _time.elapsed(); }

	public slots:
		virtual void terminate( const char * );
		virtual void terminate();
		virtual void timeout();
		virtual void log_data( logging::KVPairs & ); 
	protected: // virtual
		virtual void hideEvent( QHideEvent * );
		virtual void keyPressEvent( QKeyEvent * );
		virtual void mouseDoubleClickEvent( QMouseEvent * );
		virtual void mouseMoveEvent( QMouseEvent * );
		virtual void mousePressEvent( QMouseEvent * );
		virtual void mouseReleaseEvent( QMouseEvent * );
		virtual void showEvent( QShowEvent * );
	private:
		void log_mouse( QMouseEvent * );
	signals:
		void closed();
	private:
		QTime	_time;
		Q3Accel	_accel;
	};


};


/*!
 */
inline bool 
operator<( const QKeySequence& lhs, const QKeySequence& rhs ) {
	return QString( lhs ) < QString( rhs );
}


#endif
